<template>
  <div class="tophead">
    <div class="left" @click="goBack"><i class="icon iconfont" :class="{'icon-back': ishome}"></i></div>
    <div class="title">{{title}}</div>
    <div class="right">
      <slot name="r"></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "tophead",
  props: ["title", "backurl"],
  data() {
    return {
      ishome: true //this.$route.path != "/home" // 如果是首页则隐藏后退按钮
    };
  },
  methods: {
    goBack() {
      if (this.backurl) {
        this.$router.push(this.backurl);
      } else {
        this.$router.go(-1);
      }
    }
  },
  components: {}
};
</script>

<style lang="scss" scoped>
.tophead {
  display: flex;
  justify-content: space-between;
  background-color: $active-color;
  color: #fff;
  font-size: $text-size-imp;
  height: $th;
  line-height: $th;
  .left {
    padding-left: px2rem(25);
  }
  .title {
    text-align: center;
    flex: 1 1 auto;
  }
  .right {
    padding-right: px2rem(25);
  }
  .icon::before {
    font-size: $text-size-imp;
  }
}
</style>
